<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>activemq-stomp协议-websocket消费者</title>
    <script type="text/javascript" src="stomp.js"></script>
</head>
<body>
<script type="text/javascript">
// activemq官方有提供示例demo
// stomp.js官网地址 http://jmesnil.net/stomp-websocket/doc/

//监听的队列,需要和发送者的发送的队列名称一致否则无法接受到数据
destination = "/topic/test-stomp";

client = Stomp.client("ws://activemq.tony.com:61614/stomp");

var onconnect = function(frame) {
  client.subscribe(destination, function(message) {
     console.log(message.body); // 输出在浏览器控制台
  });
};

var name = "admin";
var passcode = "admin";
client.connect(name, passcode, onconnect);

function send(){
  client.send("/topic/test-stomp", {}, "test--11");
}
</script>
<button onclick="send()">send</button>
</body>
</html>